/**
 *
 */
package cn.dw.mm.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.dw.mm.domain.Inspectionproblem;
import cn.dw.mm.domain.Inspectionscene;
import cn.dw.mm.service.InspectionsceneService;

/**
 * @author aubrey
 * @date  下午2:40:24
 * 
 */
@Controller
@RequestMapping(value="/inspectionscene")
public class InspectionsceneController {
	
	@Autowired
	private InspectionsceneService inspectionsceneService;
	
	@RequestMapping(value="/selectByProblemId")
	@ResponseBody
	public List<Inspectionproblem> selectByProblemId(Integer problemId) {
		return inspectionsceneService.selectByProblemId(problemId);
 	}
	
	@RequestMapping(value="/selectByCondition")
	@ResponseBody
	public List<Inspectionproblem> selectByCondition(Inspectionproblem inspectionscene) {
		return inspectionsceneService.selectByCondition(inspectionscene);
	}
	
	@RequestMapping(value="/delete")
	@ResponseBody
	public String delete(Inspectionscene inspectionscene) {
		int deleteFlag = inspectionsceneService.delete(inspectionscene);
		if (deleteFlag == 1) {
			return "\"success\"";
		} else {
			return "\"fail\"";
		}
	}

	@RequestMapping(value="/insert" , method=RequestMethod.POST)
	@ResponseBody
	public String insert(HttpServletRequest request) {
		int insertFlag = inspectionsceneService.insert(request);
		if (insertFlag != 0) {
			return "\"success\"";
		} else {
			return "\"fail\"";
		}
	}

	@RequestMapping(value="/update" , method=RequestMethod.POST)
	@ResponseBody
	public int update(Inspectionscene inspectionscene) {
		return inspectionsceneService.update(inspectionscene);
	}
	
	@RequestMapping(value="/countByDomain" , method=RequestMethod.POST)
	@ResponseBody
	public List<Map<String, Object>> countByDomain() {
		return inspectionsceneService.countByDomain();
	}
}
